package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FVoucher2;
import com.ruoyi.system.service.IFVoucher2Service;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 凭证2Controller
 * 
 * @author qi
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/voucher2")
public class FVoucher2Controller extends BaseController
{
    @Autowired
    private IFVoucher2Service fVoucher2Service;

    /**
     * 查询凭证2列表
     */
    @PreAuthorize("@ss.hasPermi('system:voucher2:list')")
    @GetMapping("/list")
    public TableDataInfo list(FVoucher2 fVoucher2)
    {
        startPage();
        List<FVoucher2> list = fVoucher2Service.selectFVoucher2List(fVoucher2);
        return getDataTable(list);
    }

    /**
     * 导出凭证2列表
     */
    @PreAuthorize("@ss.hasPermi('system:voucher2:export')")
    @Log(title = "凭证2", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FVoucher2 fVoucher2)
    {
        List<FVoucher2> list = fVoucher2Service.selectFVoucher2List(fVoucher2);
        ExcelUtil<FVoucher2> util = new ExcelUtil<FVoucher2>(FVoucher2.class);
        util.exportExcel(response, list, "凭证2数据");
    }

    /**
     * 获取凭证2详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:voucher2:query')")
    @GetMapping(value = "/{fVoucherid2}")
    public AjaxResult getInfo(@PathVariable("fVoucherid2") Long fVoucherid2)
    {
        return success(fVoucher2Service.selectFVoucher2ByFVoucherid2(fVoucherid2));
    }

    /**
     * 新增凭证2
     */
    @PreAuthorize("@ss.hasPermi('system:voucher2:add')")
    @Log(title = "凭证2", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FVoucher2 fVoucher2)
    {
        return toAjax(fVoucher2Service.insertFVoucher2(fVoucher2));
    }

    /**
     * 修改凭证2
     */
    @PreAuthorize("@ss.hasPermi('system:voucher2:edit')")
    @Log(title = "凭证2", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FVoucher2 fVoucher2)
    {
        return toAjax(fVoucher2Service.updateFVoucher2(fVoucher2));
    }

    /**
     * 删除凭证2
     */
    @PreAuthorize("@ss.hasPermi('system:voucher2:remove')")
    @Log(title = "凭证2", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fVoucherid2s}")
    public AjaxResult remove(@PathVariable Long[] fVoucherid2s)
    {
        return toAjax(fVoucher2Service.deleteFVoucher2ByFVoucherid2s(fVoucherid2s));
    }
}
